import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersistence from 'vuex-persist'
const vuexLocal = new VuexPersistence({
  // 指定的存储是本地存储
  storage: window.localStorage
})
Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    user: {}, // token
    tags_list: [],
    user_mes: {}, // 用户数据
    avatar: '',
    Swiper: '',//ID
    connect2: '',//true false
    SaveMessage: {},
    checked: 0,
    scrollTop_shouye: ''
  },
  getters: {},
  mutations: {
    setUser (state, payload) {
      state.user = payload
    },
    setcategory (state, list) {
      state.tags_list = list
    },
    user_xx (state, xx) {
      state.user_mes = xx
      if (state.user_mes.currentmemLevel == null) {
        state.user_mes.currentmemLevel = { title: 'VIP1' }
      }
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
    },
    Swiper: (state, swiperID) => {
      state.Swiper = swiperID
    },
    connect2: (state, connect2) => {
      state.connect2 = connect2
    },
    SaveMessageI: (state, newVal) => {
      state.SaveMessage = newVal
    },
    checkedS: (state, newVal2) => {
      state.checked = newVal2
    },
    scrollTop_shouyeS: (state, newVal) => {
      state.scrollTop_shouye = newVal
    },
  },
  actions: {},
  modules: {},
  plugins: [vuexLocal.plugin]
})
